home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
jikes
/
src
/
modifier.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-14
|
42KB
|
1,008 lines
// $Id: modifier.cpp,v 1.5 1999/03/09 14:37:17 shields Exp $
//
// This software is subject to the terms of the IBM Jikes Compiler
// License Agreement available at the following URL:
// http://www.ibm.com/research/jikes.
// Copyright (C) 1996, 1998, International Business Machines Corporation
// and others. All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
#include "config.h"
#include "semantic.h"
AccessFlags Semantic::ProcessClassModifiers(AstClassDeclaration *class_declaration)
{
AccessFlags access_flags;
for (int i = 0; i < class_declaration -> NumClassModifiers(); i++)
{
AstModifier *modifier = class_declaration -> ClassModifier(i);
switch(modifier -> kind)
{
case Ast::ABSTRACT:
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_ABSTRACT();
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::FINAL:
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_FINAL();
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::PUBLIC:
if (access_flags.ACC_PUBLIC())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_PUBLIC();
break;
case Ast::STRICTFP:
if (access_flags.ACC_STRICTFP())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_STRICTFP();
break;
default:
ReportSemError(SemanticError::INVALID_TOP_LEVEL_CLASS_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token,
lex_stream -> Name(modifier -> modifier_kind_token));
break;
}
}
return access_flags;
}
AccessFlags Semantic::ProcessLocalClassModifiers(AstClassDeclaration *class_declaration)
{
AccessFlags access_flags;
for (int i = 0; i < class_declaration -> NumClassModifiers(); i++)
{
AstModifier *modifier = class_declaration -> ClassModifier(i);
switch(modifier -> kind)
{
case Ast::ABSTRACT:
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_ABSTRACT();
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::FINAL:
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_FINAL();
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::STRICTFP:
if (access_flags.ACC_STRICTFP())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_STRICTFP();
break;
default:
ReportSemError(SemanticError::INVALID_LOCAL_CLASS_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token,
lex_stream -> Name(modifier -> modifier_kind_token));
break;
}
}
return access_flags;
}
AccessFlags Semantic::ProcessNestedClassModifiers(AstClassDeclaration *class_declaration)
{
AccessFlags access_flags;
for (int i = 0; i < class_declaration -> NumClassModifiers(); i++)
{
AstModifier *modifier = class_declaration -> ClassModifier(i);
switch(modifier -> kind)
{
case Ast::ABSTRACT:
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_ABSTRACT();
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::FINAL:
if (access_flags.ACC_FINAL())
{
ReportSemError(SemanticError::DUPLICATE_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_FINAL();
if (access_flags.ACC_ABSTRACT())
{
ReportSemError(SemanticError::FINAL_ABSTRACT_CLASS,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
break;
case Ast::PUBLIC:
if (access_flags.ACC_PUBLIC() || access_flags.ACC_PROTECTED() || access_flags.ACC_PRIVATE())
{
ReportSemError(SemanticError::DUPLICATE_ACCESS_MODIFIER,
modifier -> modifier_kind_token,
modifier -> modifier_kind_token);
}
else access_flags.SetACC_PUBLIC();
break;
case Ast::PRIVATE:
if (access_flags.ACC_PUBLIC() || access_flags.ACC_PROTECTED() || access_flags.A